package com.system.borrow.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;

import com.google.gson.Gson;
import com.system.borrow.R;
import com.system.borrow.bean.CustomerDTO;
import com.system.borrow.bean.GloData;
import com.system.borrow.utils.SharedPreferencesUtil;

public class MainActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String json = SharedPreferencesUtil.getString(MainActivity.this, "custormer", "custormer", "");
        if(json!=null&&!json.equals("")){
            Gson gson = new Gson();
            CustomerDTO dto = gson.fromJson(json, CustomerDTO.class);
            GloData.setCustomerDTO(dto);
        }
        Handler handler = new Handler();

        Runnable updateThread = new Runnable(){
            public void run(){
                //三秒后自动跳转
                Intent intent=new Intent(MainActivity.this,HomeActivity.class);
                startActivity(intent);
                finish();
            }

        };
        handler.postDelayed(updateThread, 1000);
    }

    public void start(View view){
        Intent intent = new Intent(this,HomeActivity.class);
        startActivity(intent);
    }
}
